package com.info.zhiduoduo.repository.mapper.company;

import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.info.zhiduoduo.repository.entity.company.CompanyEntrustFileNotification;

import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.Date;
import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author Bob
 * @since 2021-11-04
 */
public interface CompanyEntrustFileNotificationMapper extends BaseMapper<CompanyEntrustFileNotification> {

	@Select(" select cefn.*, c.compname " +
			" from zdd_company_entrust_file_notification cefn " +
			" join zdd_company c on c.compid = cefn.compid " +
			" where if(#{state}=0, 1=1, cefn.state = #{state}) " +
			" and c.compname like '%${compname}%' " +
			" and cefn.createtime between #{from} and #{to} " +
			" and c.intel_crowdsource = 2 ")
	List<CompanyEntrustFileNotification> listByCompnameDate(String compname, int state, Date from, Date to);

	@Update(" update zdd_company_entrust_file_notification set state = 2 where compid = #{compid} ")
	boolean updateState(Integer compid);
}
